import { createRouter, createWebHistory } from "vue-router";
import page from "./page";
import shows from "@/redrtive/indexs.vue";

const routes = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    name: "login",
    component: () => import("../views/Login.vue"),
  },
  {
    path: "/home",
    name: "home",
    meta: {
      title: "首页",
    },
    component: () => import("../views/Home.vue"),
    children: [
      {
        path: "mainpage",
        name: "mainpage",
        component: () => import("../views/Mainpage.vue"),
      },
      {
        path: "useras",
        name: "useras",
        component: () => import("@/views/Useras.vue"),
        meta: {
          title: "个人信息",
        },
      },
      {
        path: "changcode",
        name: "changcode",
        component: () => import("@/views/ChangCode.vue"),
        meta: {
          title: "修改密码",
        },
      },
      ...page,
    ],
  },
  //刷新页面，跳到空白页面再跳回来
  {
    path: "/redirect",
    name: "redirect",
    component: () => import("@/views/Home.vue"),
    children: [
      {
        path: "/redirect/:path(.*)",
        name: "redirect-child",
        component: shows,
        meta: {
          title: "首页",
        },
      },
    ],
  },
  {
    path: "/:path(.*)+",
    name: "exception",
    component: () => import("../views/Exception.vue"),
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
